<template>
    <div class="common-layout">
        <el-container>
            <!-- 头部部分 --> 
            <el-header>
                <el-row justify="space-between" align="middle">
                    <el-col :span="6">
                        <div class="breadcrumb">
                            <el-icon><Fold /></el-icon>
                            <span>数据统计</span>
                        </div>
                    </el-col>
                    <el-col :span="3">
                        <div class="user-info">
                            <el-avatar :size="30" src="" />
                            <span class="username">admin</span>
                        </div>
                    </el-col> 
                </el-row>
            </el-header>
            <el-header class="white"></el-header>
            <!--内容部分-->
            <el-main>         
                <!--刷新部分-->
                <el-header class="refresh">
                    <el-button type="info" @click="handleRefresh">
                       <el-icon><Refresh /></el-icon>
                       刷新
                    </el-button>
                </el-header>
                <!--表格部分-->
                <el-table :data="tableData" border style="width: 100%">
                    <el-table-column prop="username" label="用户名"></el-table-column>
                    <el-table-column prop="phone" label="手机号"></el-table-column>
                    <el-table-column prop="accountTyper" label="用户类型"></el-table-column>
                    <el-table-column prop="amount" label="金额"></el-table-column>
                    <el-table-column prop="applicationTime" label="申请时间"></el-table-column>
                    <el-table-column prop="accountTyper" label="账户类型"></el-table-column>
                    <el-table-column prop="note" label="失败原因"></el-table-column>
                    <el-table-column prop="note" label="微信返回"></el-table-column>
                </el-table>
                 <div class="demo-pagination-block">
                    <el-pagination
                    v-model:current-page="pageIndex"
                    v-model:page-size="pageSize"
                    :page-sizes="[1, 2]"
                    background
                    layout="total, sizes, prev, pager, next, jumper"
                    :total=total
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    />
                </div>
            </el-main>     
        </el-container>
    </div>
</template>

<script setup>
import { wxFailList } from '@/DataStatistics/DataStatistics'
import { onMounted, ref } from 'vue'
let pageIndex=ref(1)
let pageSize=ref(2)
let total=ref(0)
onMounted(()=>{
    ReportFun()
})
// 刷新页面函数
const handleRefresh = () => {
  ReportFun()
}
let handleCurrentChange=(newPage)=>{
    pageIndex.value = newPage;
    ReportFun(); // 重新获取数据
}
let handleSizeChange=(newPage)=>{
    pageSize.value = newPage;
    ReportFun(); // 重新获取数据
}
let ReportFun = async () => {
    let data1 = {
        pageIndex: pageIndex.value,
        pageSize: pageSize.value
    };
    try {
        const res = await wxFailList(data1);
        console.log(res,12);
        if (res && res.code == 200) {
            console.log(res.dataset.list); // 确保访问正确的数据路径
            tableData.value = res.dataset.list; // 更新表格数据
            total.value = res.dataset.totalSize; // 更新总条数
        }
    } catch (error) {
        console.error("请求失败:", error);
    }
};

//表格数据
const tableData = ref([
    {
        
    },
   
])
</script>

<style lang="less" scoped>
/* 头部部分 */
.el-header{
    height: 40px;
    border-bottom: 1px solid rgb(187, 186, 186);
}
.time {
    display: inline-block;
    margin-right: 20px;
    :deep(.el-range-editor) {
        width: 285px !important;
        height: 25px;

        .el-range-input {
            font-size: 12px;
            height: 25px;
        }

        .el-range-separator {
            font-size: 12px;
        }
    }
}
.breadcrumb{
    display: flex;
    align-items: center;
}
.user-info{
    display: flex;
    align-items: center;
    gap: 8px;  /* 新增：用户名与头像间距 */
}
.white{
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/*设备转让*/
.transfer{
    background-color: rgb(223, 120, 37);
    border-color: rgb(223, 120, 37);
}
/*内容部分*/
.el-main{
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/*搜索部分*/
.search{
    width: 100%;
    border: none;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap:10px;
}
/*添加/刷新部分*/
.refresh{
    width: 100%;
    border: none;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: right;
}
/*表格部分*/
/*数据表格部分*/
:deep(.el-table) {
    width: 100% !important;
    
    .el-table__header-wrapper,
    .el-table__body-wrapper {
        width: 100% !important;
    }
    
    .el-table__header {
        width: 100% !important;
    }
    
    .el-table__body {
        width: 100% !important;
    }
    
    .el-table__row {
        height: 80px !important;
    }
    
    /* 确保表格列宽度生效 */
    .el-table__header th,
    .el-table__body td {
        text-align: center;
    }
}
/*分页器*/
.demo-pagination-block{
    width: 98%;
    display: flex;
    align-items: center;
    justify-content: right;
    margin-top: 20px;
}

</style>